
<template>
  <div class="workLIstSelect h100">
    <div class="tableConten">
      <editTableNew
        :tableSetting="workReadies"
        :tableData="workData.overhaulReadies"
        hideBtn
        ref="workReadies"
      ></editTableNew>
    </div>

    <div class="tableConten">
      <div class="tebleDiv processTable" v-if="showProcess">
        <editTableExpand
          :tableSetting="workProcessDetails"
          :tableData="workData.itemDTOs"
          hideBtn
          ref="processTable"
          showOrder
          rowKey="id"
        ></editTableExpand>
      </div>
    </div>
  </div>
</template>

<script>
import {
  getWorkListDetailsApi //查询获取试验单和表单关系
} from "@/api/orderManagement/classification";

export default {
  props: {
    rowData: {
      type: Object,
      default: () => {
        return {};
      }
    }
  },
  data() {
    return {
      selectedData: [],
      workData: {},
      listSetting: {
        selectionShow: true,
        showCustomBtn: false,
        showFilterBtn: false,
        pageConfig: {
          pageCode: "defectOrder", //页面标识，用来存储过滤器以及自定义列的时候用
          userId: this.$store.getters.userInfo.id
        },
        searchObj: {
          searchMethod: (params, sortStr) => {
            this.getTableData(params, sortStr);
          },
          queryData: {
            code: "",
            name: ""
          },
          searchArr: [
            {
              type: "input",
              label: "表单编号",
              model: "code"
            },
            {
              type: "input",
              label: "表单名称",
              model: "name"
            }
          ]
        },
        actionList: [],
        column: [
          {
            label: "表单编号",
            prop: "code"
          },
          {
            label: "表单名称",
            prop: "name"
          }
        ],
        //表格方法
        tableMethods: {
          //点击行的方法
          rowClick: val => {
            // this.gotoDetails(val);
          }
        }
      },
      workReadies: {
        btnArr: ["add"],
        column: [
          {
            label: "类别",
            textAlign: "center",
            type: "text",
            prop: "type",
            required: true
          },
          {
            label: "名称",
            textAlign: "center",
            prop: "tools",
            type: "textarea",
            autosize: true,
            required: true
          }
        ],
        title: "作业准备:",
        data: [],
        select: false,
        maxHeight: "100%",
        buttonArr: [],
        data: [],
        column: [
          {
            label: "类别",
            textAlign: "center",
            type: "text",
            prop: "type",
            required: true
          },
          {
            label: "名称",
            textAlign: "center",
            prop: "tools",
            type: "textarea",
            autosize: true,
            required: true
          }
        ]
      },

      /* 作业表单-作业过程 */
      workProcessDetails: {
        title: "作业过程",
        select: false,
        addMethons: false,
        maxHeight: 400,
        column: [
          {
            label: "序号",
            prop: "sort",
            width: "60px",
            type: "disableText"
          },
          {
            label: "作业内容",
            prop: "context",
            type: "disableText"
          },
          {
            label: "作业标准",
            prop: "contextStandard",
            type: "disableText"
          },
          {
            label: "作业风险&控制措施",
            prop: "risk",
            type: "disableText"
          },
          {
            label: "数据记录项",
            prop: "itemParams",
            type: "formItem",
            formatter: (data, row) => {
              let resultData = "";
              if (data.length > 0) {
                data.map(i => {
                  resultData =
                    resultData + i.name + "(" + i.unit + "):" + i.value + ";";
                });
              }
              return resultData || "-";
            },
            width: "220px"
          },
          {
            label: "验收级别",
            prop: "level",
            type: "disableText"
          }
        ],
        buttonArr: []
      }
    };
  },
  computed: {
    showProcess() {
      let item = this.workData.itemDTOs || [];
      return item.length != 0;
    }
  },
  created() {},
  mounted() {
    this.init();
  },
  methods: {
    init() {
      this.getWorkListDetails();
    },
    getWorkListDetails() {
      getWorkListDetailsApi(this.rowData.formId).then(res => {
        this.workData = res.data;
      });
    },
    itemParamsChange(data) {
      let resultData = "";
      if (data.length > 0) {
        data.map(i => {
          resultData =
            resultData + i.name + "(" + i.unit + "):" + i.value + ";";
        });
      }
      return resultData;
    }
  }
};
</script>
<style lang="less">
</style>